package com.example.demo.hotload;

import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import xyz.erupt.core.util.EruptSpringUtil;

public class SpringUtil {
    public static void registerClass(Class clazz) {
        DefaultListableBeanFactory autowireCapableBeanFactory = (DefaultListableBeanFactory ) EruptSpringUtil.getApplicationContext().getAutowireCapableBeanFactory();
//        autowireCapableBeanFactory.removeBeanDefinition(clazz.getName());
        AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(GenericBeanDefinition.class).getBeanDefinition();
        autowireCapableBeanFactory.registerBeanDefinition(clazz.getName(),beanDefinition);
    }
}
